
/**
 * Module dependencies.
 */

var express = require('express')  
  , http = require('http')
  , path = require('path')
  , config = require('./config/regist_controller');
	

var app = express();



// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

var server = http.createServer(app);
io = require('socket.io').listen(server);

recordVideoSocket = require('socket.io').listen(555);
socketList = [];
videoSocketList = [];
var videoStreamSK;

config.registController(app);
server.listen(3000);

recordVideoSocket.sockets.on('connection', function(socket) {
	socket.on('data',function(data){
		recordVideoSocket.sockets.emit('frame',data);
	});
});
recordVideoSocket.sockets.on('connection', function(socket) {
	videoSocketList.push(socket);
});


io.sockets.on('connection', function(socket) {
	socketList.push(socket);
});
io.sockets.on('disconnection', function(socket) {
	socketList.slice(socket);
});
process.on('uncaughtException', function(err) {
	console.log('Caught exception: ' + err);
});

